(load "sequenceablecollection.el")

(defun rem4 (l val retvalues)
  (cond ((nullp l)
	 (error (format "LinkedList : Could not remove %s ! Exiting..." oldObject)));;FIXME do not error
	((eq (car l) key)
	 (setq retvalues (append retvalues (cdr l)))
	 retvalues)
	(t
	 (rem4 (cdr l) (append (list(car l)) retvalues)))
	))

(defun LinkedList (name)
  (let* ((*class "LinkeList")
	 (*instance-name name)
	 (*value ())
	 (*super (SequenceableCollection name))
	 
	 (*dispatch
	  (lambda (msg)
	    (cond

	     ((eq msg "isEmpty")
	      (lambda ()
		(eq (length *value) 0)))

	     ((eq msg "size")
	      (lambda ()
		(length *value)))

	     ((eq msg "addFirst:")
	      (lambda (val)
		(setq *value (append (list val) *value))))

	     ((eq msg "addLast:")
	      (lambda (val)
		(setq *value (append *value (list val)))))
	  
	     (t
	      ((*super msg))
	      )
	     )))
	 )
    
    *dispatch))


	